package easy;

/**
 * 2864. 最大二进制奇数
 * 地址：https://leetcode.cn/problems/maximum-odd-binary-number/
 */
public class 最大二进制奇数_2864 {
    public static void main(String[] args) {
        System.out.println(maximumOddBinaryNumber("0101"));
    }

    static String maximumOddBinaryNumber(String s) {
        int one = 0;
        // 1的个数
        for (int i = 0; i < s.length(); i++) {
            one += s.charAt(i) -'0';
        }

        StringBuilder res = new StringBuilder();
        for (int i = 0; i < one-1; i++) {
            res.append("1");
        }
        for (int i = 0; i < s.length()-one; i++) {
            res.append("0");
        }
        res.append("1");

        return res.toString();
    }
}